import request from "@/utils/request";
import type {AjaxResult,page} from "@/utils/request"

const base = '/base/contest'
/**
 * 获取比赛列表
 * @returns Promise
 */
export const getContestList = (data : any , params?:page) : Promise<AjaxResult> => {
    return request({
        url: `${base}/list`,
        method: 'post',
        params: params,
        data:data
    })
}
/**
 * 获取最近开始的比赛列表
 * @returns Promise
 */
export const getRecentlyContest = (params?: page) : Promise<AjaxResult> => {
    return request({
        url: `${base}/getRecentlyContest`,
        method: 'get',
        params:params
    })
}
/**
 * 获取题目详情
 * @returns Promise
 */
export const getContest = (id) : Promise<AjaxResult> => {
    return request({
        url: `${base}/${id}`,
        method: 'get',
    })
}

/**
 * 获取比赛题目参照
 * @returns Promise
 */
export const getProblemRefList = (id) : Promise<AjaxResult> => {
    return request({
        url: `${base}/getProblemList/ref/${id}`,
        method: 'get',
    })
}
/**
 * 获取题目列表
 * @returns Promise
 */
export const getProblemList = (id) : Promise<AjaxResult> => {
    return request({
        url: `${base}/getProblemList/${id}`,
        method: 'get',
    })
}


/**
 * 获取题目详情
 * @returns Promise
 */
export const getProblem = (id) : Promise<AjaxResult> => {
    return request({
        url: `${base}/getProblemVO/${id}`,
        method: 'get',
    })
}


/**
 * 报名
 * @returns Promise
 */
export const register = (data : any) : Promise<AjaxResult> => {
    return request({
        url: `${base}/register`,
        method: 'post',
        data:data
    })
}


/**
 * 获取排行榜
 * @returns Promise
 */
export const getContestRank = (id, params? : page) : Promise<AjaxResult> => {
    return request({
        url: `${base}/getContestRank/s/${id}`,
        method: 'get',
        params:params
    })
}

/**
 * 获取比赛消息
 * @returns Promise
 */
export const getContestInfo = (id) : Promise<AjaxResult> => {
    return request({
        url: `${base}/info/${id}`,
        method: 'get',
    })
}
